package org.weso.lodin.datasource.config;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ResourceBundle;

public class DatasetListing {

	public static String defaultPathData = null; 

	static{
		defaultPathData = 
			ResourceBundle.getBundle(DatasetListing.class.getName().toString()).getString("load.dir");
	}


	public static File[] listIndicatorSources(){
		return listFiles(defaultPathData);
	}

	public static File[] listCustomIndicatorSources(String dir){
		return listFiles(dir);
	}
	
	private static File[] listFiles(String path){
		File dir = new File(path);
		if(dir.isDirectory()){		
			FilenameFilter filter = new FilenameFilter() {
				public boolean accept(File dir, String name) {
					return name.endsWith(".xml");
				}
			};
			return dir.listFiles(filter);
		}else{
			return new File[0];
		}

	}
//	public static void main(String []args) throws IOException{
//		File [] files = IndicatorListing.listIndicatorSources();
//		for(int i = 0; i<files.length;i++){
//			System.out.println(files[i].getCanonicalPath());
//		}
//	}
}
